import axios from "axios";

let BaseUrl = 'http://localhost:3000'

// 获取轮播图的api type:资源类型,对应以下类型,默认为 0 
//即PC 0: pc 1: android 2: iphone 3: ipad
export function getBanners(type) {
    return axios.get(`${BaseUrl}/banner?type=${type}`)
}

// 获取推荐歌单 可选参数 : limit: 取出数量 , 默认为 10 
export function getMusicList(limit) {
    return axios.get(`${BaseUrl}/personalized?limit=${limit}`)
}

// 获取歌单详情 
export function getMusicDetail(id) {
    return axios.get(`${BaseUrl}/playlist/detail?id=${id}`)
}

// 获取歌词
export function getLyric(id) {
    return axios.get(`${BaseUrl}/lyric?id=${id}`)
}

// 搜索歌曲
export function searchMusic(keyword) {
    return axios.get(`${BaseUrl}/search?keywords=${keyword}`)
}

// 手机登录
export function phoneLogin(phone, password) {
    console.log(phone, password)
    return axios.get(`${BaseUrl}/login/cellphone?phone=${phone}&password=${password}`)
}

// 获取用户的详情
export function userDetail(uid) {
    return axios.get(`${BaseUrl}/user/detail?uid=${uid}`)
}

export default {
    getBanners, getMusicList, getMusicDetail, getLyric, searchMusic, phoneLogin, userDetail
}